// cbuff.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include "cbuff.h"

int main()
{
	std::cout << "hello cbuff!" << std::endl;
	char c = 'c';
	unsigned char uc = 'u';
	int i = 10;
	int j = 123456789;
	double d = 12.7;
	double f = 123457789.123456789;
	std::string s("abcdefghijklmn");

//	cbuff buf(Endian::LITTLEENDIAN);  //little endian
	cbuff buf;  //big endian
	buf.push(c);
	buf.push(uc);
	buf.push(i);
	buf.push(j);
	buf.push(d);
	buf.push(f);
	buf.push(s.c_str(), s.length());
	std::cout << "current size:" << buf.size() << std::endl;

	char cp = 0;
	buf.peek(cp);
	buf.peek(cp);
	buf.peek(cp);
	std::cout << "cp = " << cp << std::endl;

	int slen = s.length() + 1;
	char *sz = new char[slen];
	std::memset(sz, 0, slen);
	c = 0; uc = 0; i = 0; d = 0; s = "";

	buf.pop(c).pop(uc).pop(i).pop(j).pop(d).pop(f).pop(sz, slen);
	std::cout << c << std::endl
		<< uc << std::endl
		<< i << std::endl
		<< j << std::endl
		<< d << std::endl
		<< f << std::endl
		<< sz << std::endl;
	std::cout << "current size:" << buf.size() << std::endl;
	delete []sz;

	return 0;
}

